// export type AppConfig = {
//   env: 'local' | 'staging' | 'production'
//   apiURL: string
//   mocksEnabled?: boolean
// }
import { z } from 'zod'
export const appConfigSchema = z.object({
  env: z.enum(['dev', 'test', 'prod']),
  apiURL: z.string(),
  mocksEnabled: z.boolean().default(false),
  site: z
    .object({
      NEXT_PUBLIC_API_PATHNAME: z.string(),
      // NEXT_PUBLIC_CDN_PATH: z.string(),
      // NEXT_PUBLIC_SITE_PATH: z.string()
      // # 接口地址 dev 环境
      // NEXT_PUBLIC_API_PATHNAME: z.string().default('https://dev-rt-api.olightstore.com'),
      // # CDN地址 dev 环境
      NEXT_PUBLIC_CDN_PATH: z.string().default('https://dev-rt.olicdn.com'),
      // # dev 环境 URL
      NEXT_PUBLIC_SITE_PATH: z.string().default('https://dev-rt.olightstore.com/')
    }).required()
  //   .default({
  //     // # 接口地址 dev 环境
  //     NEXT_PUBLIC_API_PATHNAME: 'https://dev-rt-api.olightstore.com',
  //     // # CDN地址 dev 环境
  //     NEXT_PUBLIC_CDN_PATH: 'https://dev-rt.olicdn.com',
  //     // # dev 环境 URL
  //     NEXT_PUBLIC_SITE_PATH: 'https://dev-rt.olightstore.com/'
  // }),
})
// }).required()
// const siteInfo = z
//   .object({
//     NEXT_PUBLIC_API_PATHNAME: z.string(),
//     // NEXT_PUBLIC_CDN_PATH: z.string(),
//     // NEXT_PUBLIC_SITE_PATH: z.string()
//     // # 接口地址 dev 环境
//     // NEXT_PUBLIC_API_PATHNAME: z.string().default('https://dev-rt-api.olightstore.com'),
//     // # CDN地址 dev 环境
//     // NEXT_PUBLIC_CDN_PATH: z.string().default('https://dev-rt.olicdn.com'),
//     // # dev 环境 URL
//     // NEXT_PUBLIC_SITE_PATH: z.string().default('https://dev-rt.olightstore.com/')
//   });
// const siteInfo1 = siteInfo.partial()
// const siteInfo2 = siteInfo.required()
// export type siteInfo1Type = z.infer<typeof siteInfo1>
// export type siteInfo2Type = z.infer<typeof siteInfo2>
// type S1 = typeof siteInfo2
// export const appConfigSchema = z.object({
//   env: z.enum(['local', 'staging', 'production']),
//   apiURL: z.string(),
//   mocksEnabled: z.boolean().default(false),
//   featureFlags: z
//     .object({
//       feature1: z.boolean().default(false),
//     })
//     .default({}),
// })
export type AppConfig = z.infer<typeof appConfigSchema>

export type KeysWithFallbackValue = 'mocksEnabled'
export type RequiredConfig = Optional<AppConfig, KeysWithFallbackValue>
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
export type DefaultKey = 'com'
export type SiteType = DefaultKey | 'de' | 'us'
